package com.blocks.blocks;

import com.blocks.ScriptBlocksApplication;
import com.blocks.controller.BlockUtils;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;

public class DetachedBlock extends Block{
	
	
	public DetachedBlock() {	
		super();
	}
	public DetachedBlock(String name, Long masterId) {
		super(name,masterId);
	}
	
	@Override
	public void init() {
		setTextureRow(0.0f);
		setTextureColumn(7.0f);
		 super.init();		 
	}
		
	@Override
	public void updateLogicalState(float tpf) {
		
		super.updateLogicalState(tpf);
		if(!this.isHudBlock()){
			if(this.isPowered()){
				int frequency = this.getFrequency(this.getBlockSides());
				//ScriptBlocksApplication.getInstance().cameraDirectionText.setText("Detach Frequency" + getFrequency(getBlockSides()));

				Vector3f vector = BlockUtils.calculatePivot(this.getBlockSides());
				if(frequency>0){
					this.setLocalTranslation(vector.mult(frequency));
				}else{
					this.setLocalTranslation(vector);
				}
			}else{
				Vector3f vector = BlockUtils.calculatePivot(this.getBlockSides());
				this.setLocalTranslation(vector);
			}
		}
	}
	
	
	
}
